<?php


abstract class Baseetudiant extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $nom;


	
	protected $prenom;


	
	protected $courriel;


	
	protected $naissance;


	
	protected $mobile;


	
	protected $mdp;


	
	protected $numetud;


	
	protected $website;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getNom()
	{

		return $this->nom;
	}

	
	public function getPrenom()
	{

		return $this->prenom;
	}

	
	public function getCourriel()
	{

		return $this->courriel;
	}

	
	public function getNaissance($format = 'Y-m-d')
	{

		if ($this->naissance === null || $this->naissance === '') {
			return null;
		} elseif (!is_int($this->naissance)) {
						$ts = strtotime($this->naissance);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [naissance] as date/time value: " . var_export($this->naissance, true));
			}
		} else {
			$ts = $this->naissance;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getMobile()
	{

		return $this->mobile;
	}

	
	public function getMdp()
	{

		return $this->mdp;
	}

	
	public function getNumetud()
	{

		return $this->numetud;
	}

	
	public function getWebsite()
	{

		return $this->website;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = etudiantPeer::ID;
		}

	} 
	
	public function setNom($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nom !== $v) {
			$this->nom = $v;
			$this->modifiedColumns[] = etudiantPeer::NOM;
		}

	} 
	
	public function setPrenom($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->prenom !== $v) {
			$this->prenom = $v;
			$this->modifiedColumns[] = etudiantPeer::PRENOM;
		}

	} 
	
	public function setCourriel($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->courriel !== $v) {
			$this->courriel = $v;
			$this->modifiedColumns[] = etudiantPeer::COURRIEL;
		}

	} 
	
	public function setNaissance($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [naissance] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->naissance !== $ts) {
			$this->naissance = $ts;
			$this->modifiedColumns[] = etudiantPeer::NAISSANCE;
		}

	} 
	
	public function setMobile($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->mobile !== $v) {
			$this->mobile = $v;
			$this->modifiedColumns[] = etudiantPeer::MOBILE;
		}

	} 
	
	public function setMdp($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->mdp !== $v) {
			$this->mdp = $v;
			$this->modifiedColumns[] = etudiantPeer::MDP;
		}

	} 
	
	public function setNumetud($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->numetud !== $v) {
			$this->numetud = $v;
			$this->modifiedColumns[] = etudiantPeer::NUMETUD;
		}

	} 
	
	public function setWebsite($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->website !== $v) {
			$this->website = $v;
			$this->modifiedColumns[] = etudiantPeer::WEBSITE;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->nom = $rs->getString($startcol + 1);

			$this->prenom = $rs->getString($startcol + 2);

			$this->courriel = $rs->getString($startcol + 3);

			$this->naissance = $rs->getDate($startcol + 4, null);

			$this->mobile = $rs->getInt($startcol + 5);

			$this->mdp = $rs->getString($startcol + 6);

			$this->numetud = $rs->getInt($startcol + 7);

			$this->website = $rs->getString($startcol + 8);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 9; 
		} catch (Exception $e) {
			throw new PropelException("Error populating etudiant object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(etudiantPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			etudiantPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(etudiantPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = etudiantPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += etudiantPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = etudiantPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = etudiantPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getNom();
				break;
			case 2:
				return $this->getPrenom();
				break;
			case 3:
				return $this->getCourriel();
				break;
			case 4:
				return $this->getNaissance();
				break;
			case 5:
				return $this->getMobile();
				break;
			case 6:
				return $this->getMdp();
				break;
			case 7:
				return $this->getNumetud();
				break;
			case 8:
				return $this->getWebsite();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = etudiantPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getNom(),
			$keys[2] => $this->getPrenom(),
			$keys[3] => $this->getCourriel(),
			$keys[4] => $this->getNaissance(),
			$keys[5] => $this->getMobile(),
			$keys[6] => $this->getMdp(),
			$keys[7] => $this->getNumetud(),
			$keys[8] => $this->getWebsite(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = etudiantPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setNom($value);
				break;
			case 2:
				$this->setPrenom($value);
				break;
			case 3:
				$this->setCourriel($value);
				break;
			case 4:
				$this->setNaissance($value);
				break;
			case 5:
				$this->setMobile($value);
				break;
			case 6:
				$this->setMdp($value);
				break;
			case 7:
				$this->setNumetud($value);
				break;
			case 8:
				$this->setWebsite($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = etudiantPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNom($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setPrenom($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setCourriel($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setNaissance($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setMobile($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setMdp($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setNumetud($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setWebsite($arr[$keys[8]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(etudiantPeer::DATABASE_NAME);

		if ($this->isColumnModified(etudiantPeer::ID)) $criteria->add(etudiantPeer::ID, $this->id);
		if ($this->isColumnModified(etudiantPeer::NOM)) $criteria->add(etudiantPeer::NOM, $this->nom);
		if ($this->isColumnModified(etudiantPeer::PRENOM)) $criteria->add(etudiantPeer::PRENOM, $this->prenom);
		if ($this->isColumnModified(etudiantPeer::COURRIEL)) $criteria->add(etudiantPeer::COURRIEL, $this->courriel);
		if ($this->isColumnModified(etudiantPeer::NAISSANCE)) $criteria->add(etudiantPeer::NAISSANCE, $this->naissance);
		if ($this->isColumnModified(etudiantPeer::MOBILE)) $criteria->add(etudiantPeer::MOBILE, $this->mobile);
		if ($this->isColumnModified(etudiantPeer::MDP)) $criteria->add(etudiantPeer::MDP, $this->mdp);
		if ($this->isColumnModified(etudiantPeer::NUMETUD)) $criteria->add(etudiantPeer::NUMETUD, $this->numetud);
		if ($this->isColumnModified(etudiantPeer::WEBSITE)) $criteria->add(etudiantPeer::WEBSITE, $this->website);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(etudiantPeer::DATABASE_NAME);

		$criteria->add(etudiantPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNom($this->nom);

		$copyObj->setPrenom($this->prenom);

		$copyObj->setCourriel($this->courriel);

		$copyObj->setNaissance($this->naissance);

		$copyObj->setMobile($this->mobile);

		$copyObj->setMdp($this->mdp);

		$copyObj->setNumetud($this->numetud);

		$copyObj->setWebsite($this->website);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new etudiantPeer();
		}
		return self::$peer;
	}

} 